﻿#region System Namespace
using System;
using System.Linq;
using System.Threading;
#endregion System Namespace

#region Foreign Namespace
#endregion Foreign Namespace

#region Styx Namespace
using Styx;
using Styx.Plugins;
using Styx.WoWInternals.WoWObjects;
using Styx.CommonBot.Frames;
using Styx.WoWInternals;
#endregion Styx Namespace

namespace Auction
{
    public partial class Auction : HBPlugin
    {
        public void InteractWithAuctioneer()
        {
            try
            {
                var auctioneers =
                    ObjectManager.GetObjectsOfType<WoWUnit>(false, false).Where(
                        o => o != null && o.Entry == MIRsettings.Instance.AuctioneerID);
                foreach (WoWUnit obj in auctioneers.Where(obj => obj != null).Where(obj => obj.WithinInteractRange))
                {
                    Thread.Sleep(500);
                    obj.Interact();
                    Log("Interacting with auctioneer NPC");
                }
            }
            catch (Exception)
            {
                Log("Unable to find Auctioneer using WoWHead ID : '" + MIRsettings.Instance.AuctioneerID + "'");
            }
        }
    }
}